home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / font / LayoutPathImpl$SegmentPathBuilder.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  1.9 KB  |  116 lines

  1. package sun.font;
  2.  
  3. import sun.font.LayoutPathImpl.EndType;
  4.  
  5. public final class LayoutPathImpl$SegmentPathBuilder {
  6.    private double[] data;
  7.    // $FF: renamed from: w int
  8.    private int field_0;
  9.    // $FF: renamed from: px double
  10.    private double field_1;
  11.    // $FF: renamed from: py double
  12.    private double field_2;
  13.    // $FF: renamed from: a double
  14.    private double field_3;
  15.    private boolean pconnect;
  16.    // $FF: synthetic field
  17.    static final boolean $assertionsDisabled = !LayoutPathImpl.class.desiredAssertionStatus();
  18.  
  19.    public void reset(int var1) {
  20.       if (this.data != null && var1 <= this.data.length) {
  21.          if (var1 == 0) {
  22.             this.data = null;
  23.          }
  24.       } else {
  25.          this.data = new double[var1];
  26.       }
  27.  
  28.       this.field_0 = 0;
  29.       this.field_1 = this.field_2 = (double)0.0F;
  30.       this.pconnect = false;
  31.    }
  32.  
  33.    public LayoutPathImpl.SegmentPath build(LayoutPathImpl.EndType var1, double... var2) {
  34.       if (!$assertionsDisabled && var2.length % 2 != 0) {
  35.          throw new AssertionError();
  36.       } else {
  37.          this.reset(var2.length / 2 * 3);
  38.  
  39.          for(int var3 = 0; var3 < var2.length; var3 += 2) {
  40.             this.nextPoint(var2[var3], var2[var3 + 1], var3 != 0);
  41.          }
  42.  
  43.          return this.complete(var1);
  44.       }
  45.    }
  46.  
  47.    public void moveTo(double var1, double var3) {
  48.       this.nextPoint(var1, var3, false);
  49.    }
  50.  
  51.    public void lineTo(double var1, double var3) {
  52.       this.nextPoint(var1, var3, true);
  53.    }
  54.  
  55.    private void nextPoint(double var1, double var3, boolean var5) {
  56.       if (var1 != this.field_1 || var3 != this.field_2) {
  57.          if (this.field_0 == 0) {
  58.             if (this.data == null) {
  59.                this.data = new double[6];
  60.             }
  61.  
  62.             if (var5) {
  63.                this.field_0 = 3;
  64.             }
  65.          }
  66.  
  67.          if (this.field_0 != 0 && !var5 && !this.pconnect) {
  68.             this.data[this.field_0 - 3] = this.field_1 = var1;
  69.             this.data[this.field_0 - 2] = this.field_2 = var3;
  70.          } else {
  71.             if (this.field_0 == this.data.length) {
  72.                double[] var6 = new double[this.field_0 * 2];
  73.                System.arraycopy(this.data, 0, var6, 0, this.field_0);
  74.                this.data = var6;
  75.             }
  76.  
  77.             if (var5) {
  78.                double var10 = var1 - this.field_1;
  79.                double var8 = var3 - this.field_2;
  80.                this.field_3 += Math.sqrt(var10 * var10 + var8 * var8);
  81.             }
  82.  
  83.             this.data[this.field_0++] = var1;
  84.             this.data[this.field_0++] = var3;
  85.             this.data[this.field_0++] = this.field_3;
  86.             this.field_1 = var1;
  87.             this.field_2 = var3;
  88.             this.pconnect = var5;
  89.          }
  90.       }
  91.    }
  92.  
  93.    public LayoutPathImpl.SegmentPath complete() {
  94.       return this.complete(EndType.EXTENDED);
  95.    }
  96.  
  97.    public LayoutPathImpl.SegmentPath complete(LayoutPathImpl.EndType var1) {
  98.       if (this.data != null && this.field_0 >= 6) {
  99.          LayoutPathImpl.SegmentPath var2;
  100.          if (this.field_0 == this.data.length) {
  101.             var2 = new LayoutPathImpl.SegmentPath(this.data, var1);
  102.             this.reset(0);
  103.          } else {
  104.             double[] var3 = new double[this.field_0];
  105.             System.arraycopy(this.data, 0, var3, 0, this.field_0);
  106.             var2 = new LayoutPathImpl.SegmentPath(var3, var1);
  107.             this.reset(2);
  108.          }
  109.  
  110.          return var2;
  111.       } else {
  112.          return null;
  113.       }
  114.    }
  115. }
  116.